-
Notifications
You must be signed in to change notification settings - Fork 40
proxmox_zone - new module #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proxmox_zone - new module #176
Conversation
- List zones
- Move sdn locking functions to proxmox module_utils
Thanks for this work! :-) Can you have a look at the sanity checks (for this and the other PRs you've created) |
- Fix PEP8 issues - Fix Doc issues for dnszone - Add workaround for author string - Add attribute check_mode and diff_mode - Add no_log=False for lock_token as this is not a secret - Add proxmox_zone to runtime.yml
1172fe3
to
a5773bf
Compare
I've fixed sanity issues in all PRs please check. let me know if anything else is needed. Thanks. |
sorry 1 more question I was trying merge on my local repo and it is giving merge conflicts for because sanity check is giving this without that |
I'm not too familiar why, but what I know is that each PR that adds a new module should add it to that list in the
The reason you get merge conflicts is because in each branch you add one line after the line that is in the current main. Which, after merging one of those branches, has changed into something else. So from git's perspective your branches want to change the same line. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #176 +/- ##
==========================================
+ Coverage 60.29% 63.57% +3.28%
==========================================
Files 53 60 +7
Lines 5641 6315 +674
Branches 1127 1235 +108
==========================================
+ Hits 3401 4015 +614
- Misses 2089 2128 +39
- Partials 151 172 +21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Ok. let me add it. and also let me check what I can do for unit tests. |
Hi this is also ready. once this gets merged I'll rebase my vnet and subnet branches so they'll also get locking function for testing. Thanks. |
Let's focus on this and #183 first then. I'm not in a hurry to get a release out. I do think after your PRs have been merged we have a nice juicy release! ;-) |
@IamLunchbox Can you take a look at this again, if you're happy, I'm happy. I don't use SDN/PVE firewalls (nor understand how they work 😅 ). @JanaHoch Thanks for making the unit tests, they seem to pass just fine and look extensive! |
Hi @Thulium-Drake / @IamLunchbox , Sorry I just saw that I forgot to convert few ansible boolean to proxmox bool. I've fixed it now with 7b24750 . Let me know if you see anything else I've missed. I used |
Just FYI: |
No worries. take your time. I'll also try to finish writing unit tests for remaining PRs. Thanks. |
plugins/module_utils/proxmox.py
Outdated
return self.proxmox_api.cluster().sdn().lock().post() | ||
except Exception as e: | ||
self.module.fail_json( | ||
msg=f'Failed to acquire global sdn lock {e}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Thulium-Drake The last time i contributed to community.general f-strings were not allowed due to backwards compatibility. But sanity-tests pass on this code. Do you know why? Has python2 compatibility been deprecated for this collection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In README python 3.7 is mentioned so I thought it should be ok. If not let me know i can update but python2 deprecated when the only python I knew was a snake... :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah i see, very nice.
So we could use type hints, as well now, @Thulium-Drake ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ehm, good question, @felixfontein what are the guidelines in community.general
for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether Python 2 compatibility is still needed depends on a) the supported ansible-core versions of the collection, and b) on the collection itself as well (there might be further restrictions on target version numbers).
For community.general, we usually support all ansible-core versions that are not EOL and haven't been EOL for more than a few weeks at the time of a new major release. That means that community.general 11.0.0 (released in spring) still supports ansible-core 2.16, which still supports Python 2.7 on the target. But the next major release, community.general 12.0.0 (should be released in November), will only support ansible-core >= 2.17, and thus will be Python 3.7+.
(I'm not saying this policy is great, but at least it is predictable and doesn't let the CI matrix explode... like community.crypto 2.x.y, which supports everything from Ansible 2.9 up to ansible-core 2.19, or community.internal_test_tools and community.library_inventory_filtering_v1, which even cover Ansible 2.9 up to ansible-core devel :) )
community.proxmox 1.0.0 said it only supports ansible-core 2.17+ from the beginning, so it was always Python 3.7+.
plugins/modules/proxmox_zone.py
Outdated
EXAMPLES = r""" | ||
- name: Get all zones | ||
community.proxmox.proxmox_zone: | ||
api_user: "root@pam" | ||
api_password: "{{ vault.proxmox.root_password }}" | ||
api_host: "{{ pc.proxmox.api_host }}" | ||
validate_certs: no | ||
- name: Get all simple zones | ||
community.proxmox.proxmox_zone: | ||
api_user: "root@pam" | ||
api_password: "{{ vault.proxmox.root_password }}" | ||
api_host: "{{ pc.proxmox.api_host }}" | ||
validate_certs: no | ||
type: simple | ||
register: zones |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module tries to retreive information and change SDNs in one go. IMHO, this is counterintuitive and not granular.
Since other modules within ansible core and in this collection are also splitting gathering information and changing things into two different modules, I would suggest doing the same here and creating module zone_info
. As an example: The usage between gathering info and changing stuff is split between proxmox_vm_info
and proxmox_vm
or slurp
and copy
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, I did it in this and few other PRs as well because even for update/create/delete I wanted to verify if it exists or not and I'm calling that get method. if I split it in zone_info
and zone
module is it ok if i duplicate those get methods? or let me see if i can create an object of zone_info
in zone
and try to access those get methods like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you could create the information retrieval function in module_utils
.
I checked the usage of some other examples in there and there are some, which only have one call through their associated module, so two usages in your case should be fine. I don't know if cross-calling functions from two modules is allowed or not. But I suppose, that module_utils
is exactly the place for these kind of use cases-
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok thanks, I'll split this and other modules and add the get methods in module_utils.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IamLunchbox / @Thulium-Drake , Do you think it'll be better to create another class in module_utils
another base class for all SDN utilities. I can add get methods from all other PRs there and all these locking functions. so that It'll be bit more organized? if this sounds stupid let me know I can always keep it in original base class. And of course this new class's parent will be ProxmoxAnsible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this PR should be ready now. I've created new SDN base class. and fixed all the other things you mentioned and marked them resolved. except for few which need confirmation. if there is still any change needed let me know.
- community.proxmox.attributes | ||
""" | ||
|
||
EXAMPLES = r""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Thulium-Drake Should example tasks be added to the intergration tests only after #7 is solved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we're still working on it (progress is a bit slow unfortunately), but my plan is that after we get the server up, we'll start working on a molecule setup that will validate some basic modules first.
And then expand it where we can :-)
Meh, sorry for the spam! I should've done the reviews in one review-context I guess? Anyways, I am about 50% done now, mostly the documentation. Please remember to prepare a changelog fragment. |
Don't worry about spam. It's okay. |
You are right, the new module should be picked up automatically. Regarding the update of module utils: I, personally, think, that a fragment for these new functions is not needed. They are focused on sdn usage and won't impact other modules. @Thulium-Drake , what do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finished the rest of the file review. I did only cursory read the unit test, since it will probably get changed.
plugins/modules/proxmox_zone.py
Outdated
EXAMPLES = r""" | ||
- name: Get all zones | ||
community.proxmox.proxmox_zone: | ||
api_user: "root@pam" | ||
api_password: "{{ vault.proxmox.root_password }}" | ||
api_host: "{{ pc.proxmox.api_host }}" | ||
validate_certs: no | ||
- name: Get all simple zones | ||
community.proxmox.proxmox_zone: | ||
api_user: "root@pam" | ||
api_password: "{{ vault.proxmox.root_password }}" | ||
api_host: "{{ pc.proxmox.api_host }}" | ||
validate_certs: no | ||
type: simple | ||
register: zones |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you could create the information retrieval function in module_utils
.
I checked the usage of some other examples in there and there are some, which only have one call through their associated module, so two usages in your case should be fine. I don't know if cross-calling functions from two modules is allowed or not. But I suppose, that module_utils
is exactly the place for these kind of use cases-
- Move SDN locking methods from ProxmoxAnsible class to ProxmoxSdnAnsible - Add ge_zones() method to ProxmoxSdnAnsible As we will be splitting zone module into zone and zone_info
- Split proxmox_zone and create proxmox_zone_info - Rename variable type to zone_type
b63366e
to
f9e0ccb
Compare
- also fix minor issues in proxmox_zone,proxmox_zone_info, proxmox_sdn.
f9e0ccb
to
5fef669
Compare
Correct, new modules don't require changelogs as the changelog tool will pick them up itself |
Thanks @JanaHoch and @IamLunchbox for your work! I'm sorry I can't help you more with the intricate details of the python programming. I'm more of a Ansible poweruser and not so much a Python programmer 😅, but I'm happy to help where I can! With regards to the module, the tests pass and you both seem happy with the results ;-) |
Hm, I wouldve liked to review the fixed result - I did not know if the changes are all implemented. But what done is done i guess :| |
Well, it's not released yet, I could still revert it if you want. Please let me know how you would like to proceed :-) |
In case anyone wonders on how that works: it looks at the top-level |
Thank you for the heads up felix :) I finished reviewing and created #189 to fix the missing release tag. |
Thank you all |
SUMMARY
New modules to list/creat/update/delete SDN zones
ISSUE TYPE
COMPONENT NAME
proxmox_zone
proxmox_zone_info
ADDITIONAL INFORMATION
This is part of #30